class A:
    def __init__(self, name, age):
        self.name = name
        self.__age = age

    @property
    def age(self):
        return self.__age

    # 注意名称
    @age.setter
    def age(self, age):
        if age > 100 or age < 0:
            raise Exception("年龄输入有误")
        self.__age = age

    def get_age(self):
        return self.__age


a = A("hello", 19)
print(a.age)
a.age = -1
print(a.age)

